%% 高信噪比下的遍历容量

clear
clc
NUM_timesamples = 1000;
tilde_h = (randn(NUM_timesamples)+ j*randn(NUM_timesamples))/sqrt(2);
Pathloss = 1;
h = sqrt(Pathloss)*tilde_h;
SNR_dB = -10:5:30;
for I_SNR = 1: length(SNR_dB)
    rho = 10^(SNR_dB(I_SNR)/10);
    for t = 1:NUM_timesamples
    Capacity_temp(t) = log2(abs(rho*h(t)*h(t)') );
    end
    Capacity(I_SNR)= sum(Capacity_temp)/NUM_timesamples;
end
figure(1)
hold on
plot(SNR_dB,Capacity, 'ro-')
legend('Ergodic Capacity', 'Location', 'NorthWest'),
xlabel('\rho (in dB)')
ylabel('Ergodic Capacity (bps/Hz)')
grid
